package logger

import "sync"

var logStoreInstance *logStore = nil // 单例
var once sync.Once
var LogFormat = "%s === IP: %s === URL: %s === HTTP-STATUS: %d === PARAMS: %s " // 收集 时间,ip, uri, http状态码, 传递的参数

func GetLogStoreInstance() {
	once.Do(func() {
		logStoreInstance = &logStore{logs: make([]string, 100), num: 0}
	})
}

func SaveLog(log string) {
	logStoreInstance.saveLog(log)
}

func SaveLogs(logs []string) {
	logStoreInstance.saveLogs(logs)
}

func ClearLogs() {
	logStoreInstance.clearLogger()
}

func GetLogs() (int, []string) {
	return logStoreInstance.getLogs()
}
